<?php
	if (isset($_GET["pUrl"]) &&isset($_GET["pM"]) &&isset($_GET["pC"])&&isset($_GET["cI"]) ) {
	$to = $_GET["pUrl"];
	$Money = $_GET["pM"];//单位：分
	$Count = $_GET["pC"];
        $cartId = $_GET["cI"];
	$TotalMoney = $Money * 100;//单位换算为元
	//echo $to;
	//header('Location: ' . $to) ;
}
//echo $wxPayHelper->create_biz_package();
?> 
<?php
include_once("WxPayHelper.php");


$commonUtil = new CommonUtil();
$wxPayHelper = new WxPayHelper();


$wxPayHelper->setParameter("bank_type", "WX");
$wxPayHelper->setParameter("body", "场地预定支付费用");
$wxPayHelper->setParameter("attach", $cartId);
$wxPayHelper->setParameter("partner", "1220336601");
$wxPayHelper->setParameter("out_trade_no", $commonUtil->create_noncestr());
$wxPayHelper->setParameter("total_fee", $TotalMoney);
$wxPayHelper->setParameter("fee_type", "1");
$wxPayHelper->setParameter("notify_url", "http://121.42.25.67/billyn-dev/pay/weixin/notice.php");
$wxPayHelper->setParameter("spbill_create_ip", "127.0.0.1");
$wxPayHelper->setParameter("input_charset", "GBK");
?>
<html>
  <HEAD><TITLE>微信安全支付</TITLE>
    <META charset=utf-8>
    <META name=viewport content="width=device-width, user-scalable=no, initial-scale=1">
    <LINK rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
    <SCRIPT src="http://code.jquery.com/jquery-1.10.2.min.js"></SCRIPT>
    <SCRIPT src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></SCRIPT>
  </HEAD>
<body>
    <div data-role="page" id="page1">
	  <div data-role="header">
	   <h1></h1>
	  </div>
      <div data-role="content">
        <UL data-role="listview" data-inset="true">
          <LI>
            <P>
              <div class="fieldcontain">
                <label>支付名称：</label>
                <input name="paid_count" id="paid_count" value="场地预定支付费用" type="text" readonly="readonly" >
              </div>
              <div class="fieldcontain">
                <label>支付总金额：</label>
                <input name="paid_money" id="paid_money" value="<?php echo $Money ?>" type="text" readonly="readonly">
                <input type="hidden" id="url" value="<?php echo $to;?>">
                <input type="hidden" id="cartId" value="<?php echo $cartId;?>">
              </div>
                <div class="fieldcontain">
                <a  data-role="button" id="getBrandWCPayRequest" href="javascript:void(0);">确认支付</a>
              </div>
            </P>
          </LI>
        </UL>			  
      </div>
	<div data-theme="a" data-role="footer" data-position="fixed">
	<h3>比邻平台</h3>
	</div>
    </div>
<script language="javascript">
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    WeixinJSBridge.call('hideOptionMenu');
                          //公众号支付
                          jQuery('a#getBrandWCPayRequest').click(function(e){
                                WeixinJSBridge.invoke('getBrandWCPayRequest',<?php echo $wxPayHelper->create_biz_package(); ?>,function(res){
                                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                                                var x= document.getElementById("url").value;
                                                location.href = x;
                                     }
                                });
                                });
                          WeixinJSBridge.log('pay ready.');

                          }, false)
</script>
</body>
</html>